package mycom.example.gameview;

import java.util.Random;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;

public class MyShape extends Thread {
	private float cx;
	private float cy;
	int shape;

	Random rnd = new Random();

	int r = rnd.nextInt(255);
	int g = rnd.nextInt(255);
	int b = rnd.nextInt(255);

	public MyShape() {
		cx = rnd.nextInt(330) + 100;
		cy = rnd.nextInt(650) + 100;

	}

	public MyShape(float x, float y) {
		cx = x;
		cy = y;

	}

	@Override
	public void run() {
		while (cx < 450) {
			cx = cx + 2;
			try {
				Thread.sleep(500);
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

	}

	public void display(Canvas c) {
		Paint paint = new Paint();
		shape = rnd.nextInt(3) + 1;

		paint.setColor(Color.rgb(r, g, b));

		if (shape == 1) {
			c.drawCircle(cx, cy, 30, paint);
		} else if (shape == 2) {
			c.drawRect(cx, cy, (cx + 60), (cy + 60), paint);
		} else {
			Path path = new Path();
			path.moveTo(cx, cy - 45);
			path.lineTo(cx + 45, cy + 45);
			path.lineTo(cx - 45, cy + 45);

			c.drawPath(path, paint);
		}

	}
}
